(function () {
	var r, o, t;

	// This function is copied from yahoo.js.
	// This keeps this file free of dependencies.
	function hasOwnProperty(o, prop) {
		if (Object.prototype.hasOwnProperty) {
			return o.hasOwnProperty(prop);
		}
		return typeof o[prop] !== "undefined" &&
		o.constructor.prototype[prop] !== o[prop];
	}

	function parseQueryString(s) {
		var r, a, p;

		r = {};
		a = s.split('&');
		for (i = 0; i < a.length; i++) {
			p = a[i].split('=');
			if (p.length === 2 && p[0].length > 0) {
				r[p[0]] = unescape(p[1]);
			}
		}
		return r;
	}

	// Match things like parent.frames["aaa"].top.frames[0].frames['bbb']
	r = /^(?:(?:(top|parent|frames\[(?:(?:['"][a-zA-Z\d-_]*['"])|\d+)\]))(?:\.|$))+/;

	o = parseQueryString(location.hash.substr(1));
	console.info('o hash='+location.hash);
	console.dir(o);
	// The following properties may be missing as a result of preloading
	// this file for example. Simply do nothing in that case...
	if( hasOwnProperty(o, "iframe_dst") && hasOwnProperty(o, "message") &&
			hasOwnProperty(o, "domain") && hasOwnProperty(o, "uri") ){
		
		if (!r.test(o.iframe_dst)) {
			throw new Error("Invalid iframe_dst: " + o.iframe_dst);
		}

		// Safe to eval...
		t	= eval("parent." + o.iframe_dst);
		console.info("proxying from " + parent.location.href);
		console.info("proxying to " + t.location.href);
		console.info('iframe_dst='+ "parent." + o.iframe_dst);
		console.info('message='+ o.message);

		// Let the application know a message has been received.
		t.crossframe_rpc.event.fire(o.message, o.domain, o.uri);
	}
})();
